$(function() {

    //合作商
    $.ajax({
        type: 'post',
        // url: 'https://wapp.mofisher.com/v2/office/together',
        url: 'https://t2.uma.com/v2/office/together',
        data: {
            page:1,
            size:8
        },
        dataType: 'jsonp',
        jsonp: 'callback',
        success: function(result) {
            var datas = result.datainfo.news;
            for (var i = 0; i < datas.length; i++) {
                var list = '<li><span style="background: url('+ datas[i].img_url +') 100% 100%;background-repeat: no-repeat;background-position: center;background-size: cover;"></span></li>';
                $('.photos-rows').append(list); 
            }
            
            var listMb = "";
            for(var i = 0; i < datas.length; i++){
                 listMb += "<li class='solution-banner-item'><div class='img-container'><span style='background:url("+datas[i].img_url +") 100% 100%;background-position: center;display:inline-block;width:100%;height: 100%;background-repeat: no-repeat;background-size: cover;'></span></div></li>"
            }
            $('.solution-banner-1').append(listMb);
            animate(1,datas.length)

        },
        error: function(e) {

        }
    });

});
// 传入数据长度和速度
function animate(speed,length){
    var oUl = document.getElementsByClassName('solution-banner-1')[0];
    var oUl2 = document.getElementsByClassName('solution-banner-1')[1]
    oUl.innerHTML = oUl.innerHTML + oUl.innerHTML;
    oUl2.innerHTML = oUl.innerHTML;
    var oLi = document.getElementsByClassName("solution-banner-item")[0];
    oUl.style.width = oLi.offsetWidth * length * 2 + "px";
    oUl2.style.width = oLi.offsetWidth * length * 2 + "px";
    oUl.style.left = -oLi.offsetWidth * length + 'px';
    function move(){
          if(oUl.offsetRight == 0) {
              oUl2.style.left = -oLi.offsetWidth * length + 'px'
          }
          if (oUl.offsetLeft > 0) {
            oUl.style.left = -oUl.offsetWidth / 2 + "px"
          }
          if(oUl2.offsetLeft < -oUl2.offsetWidth / 2) {
            oUl2.style.left = 0
          }
          oUl.style.left = oUl.offsetLeft + speed + "px";
          oUl2.style.left = oUl2.offsetLeft - speed + "px"
    }
    var timer = setInterval(move,30)
}